Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build IDL Anchor 0.30 #48

Merged
merged 17 commits into from
Jun 19, 2024
Merged

Build IDL Anchor 0.30 #48

merged 17 commits into from
Jun 19, 2024

Conversation

ebatsell
Copy link
Collaborator

@ebatsell ebatsell commented Jun 12, 2024

Fixes to build IDL for new Anchor 0.30 spec. New IDL spec breaking changes:

  • usize not supported in instructions or accounts
  • Need to implement IdlBuild for types that are non-native
    • Added manual deserialization functions for stake pool and validator list so we don't need to define them
  • New features needed in build files

@ebatsell ebatsell changed the base branch from master to steward-test-branch June 12, 2024 16:09
@ebatsell ebatsell changed the base branch from steward-test-branch to master June 17, 2024 14:48
@ebatsell ebatsell marked this pull request as ready for review June 17, 2024 15:52
@ebatsell ebatsell requested a review from coachchucksol June 17, 2024 16:05
Copy link
Contributor

@CoachChuckFF CoachChuckFF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the TODO here? Check the validator list address to the config?

@@ -10,7 +10,7 @@ pub const EPOCH_PROGRESS_MAX: f64 = 0.99;
// Cannot go more than 100 epochs without scoring
pub const NUM_EPOCHS_BETWEEN_SCORING_MAX: u64 = 100;
// Cannot score validators in under 100 slots, to submit 1 instruction per validator
pub const COMPUTE_SCORE_SLOT_RANGE_MIN: usize = 100;
pub const COMPUTE_SCORE_SLOT_RANGE_MIN: u64 = 100;
#[cfg(feature = "mainnet-beta")]
pub const VALIDATOR_HISTORY_FIRST_RELIABLE_EPOCH: usize = 520;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just change these right away to u64?

Copy link
Contributor

@CoachChuckFF CoachChuckFF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe address the TODO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make BITMASK_SIZE and all other const variables u64

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For variables that are explicitly used for indexing into arrays or defining size I think we should keep them as usize, as long as they don't need to be exposed in the IDL

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make the index a uXX as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make all constants uXX

@ebatsell
Copy link
Collaborator Author

What's the TODO here? Check the validator list address to the config?

@CoachChuckFF I have a task in the "additional tweaks to steward" list to add validator_list to config, skipping for now since it may move around some data in the account so waiting until a future deploy of the program

@@ -388,9 +425,10 @@ impl StewardState {
.num_pool_validators
.checked_sub(1)
.ok_or(StewardError::ArithmeticError)?;
let num_pool_validators = self.num_pool_validators as usize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a lot nicer!

@@ -10,7 +10,7 @@ use spl_stake_pool::{

use crate::{errors::StewardError, Config, Delegation};

pub fn get_stake_pool(account: &AccountLoader<Config>) -> Result<Pubkey> {
pub fn get_stake_pool_address(account: &AccountLoader<Config>) -> Result<Pubkey> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change

Copy link
Contributor

@CoachChuckFF CoachChuckFF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me!

Copy link
Contributor

@coachchucksol coachchucksol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me!

@ebatsell ebatsell merged commit 0527b29 into master Jun 19, 2024
6 checks passed
@ebatsell ebatsell deleted the evan/anchor-idl-fixes branch June 19, 2024 23:25
anchor-lang = "0.30.0"
anchor-lang = { features = ["idl-build"], version = "0.30.0" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I was just passing by and saw you've enabled the idl-build feature for the default target. This should be avoided, as the IDL generation process is a separate build process that doesn't use Solana's build tools.

This seems harmless now other than adding a bit of unnecessary compilation, but it could very well break the compilation of your program in the future. For this reason, I added warnings for this usage in coral-xyz/anchor#3061.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acheroncrypto thanks for the input, will make the change!

ebatsell added a commit that referenced this pull request Oct 7, 2024
Recommendation from #48. Should help compilation issues downstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants